package com.toilet.easyvideo.api.controller;

import cn.hutool.json.JSONUtil;
import com.toilet.easyvideo.request.LoginRequest;
import com.toilet.easyvideo.request.NormalRegisterRequest;
import com.toilet.easyvideo.response.LoginResponse;
import com.toilet.easyvideo.response.RegisterResponse;
import com.toilet.easyvideo.service.LoginService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author snowfrake
 * @date 2023/11/3
 */
@RestController
@RequestMapping("/api/auth")
@Slf4j
public class LoginController {
    @Resource
    private LoginService loginService;

    @PostMapping("/login")
    public LoginResponse login(@RequestBody LoginRequest loginRequest) {
        log.info("接收到的请求参数：{}", JSONUtil.toJsonStr(loginRequest));
        LoginResponse response = loginService.login(loginRequest);
        return response;
    }

    /**
     * 普通注册
     *
     * @param loginRequest
     * @return
     */
    @PostMapping("/normal_register")
    public RegisterResponse normalRegister(@RequestBody NormalRegisterRequest loginRequest) {
        log.info("接收到的请求参数：{}", JSONUtil.toJsonStr(loginRequest));
        return loginService.normalRegister(loginRequest);
    }
}
